home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / bin / screen < prev    next >
Encoding:
Text File  |  2009-06-02  |  2.5 KB  |  64 lines

  1. #!/bin/sh
  2. #
  3. #    screen wrapper script
  4. #    Copyright (C) 2008 Canonical Ltd.
  5. #
  6. #    Authors: Dustin Kirkland <kirkland@canonical.com>
  7. #
  8. #    This program is free software: you can redistribute it and/or modify
  9. #    it under the terms of the GNU General Public License as published by
  10. #    the Free Software Foundation, version 3 of the License.
  11. #
  12. #    This program is distributed in the hope that it will be useful,
  13. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. #    GNU General Public License for more details.
  16. #
  17. #    You should have received a copy of the GNU General Public License
  18. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  
  20. # Create the screen-profiles directory, if it doesn't already exist
  21. [ -d "$HOME/.screen-profiles" ] || mkdir -p "$HOME/.screen-profiles"
  22.  
  23. # If $HOME/.screenrc exists but $HOME/.screen-profiles/profile does not,
  24. # this shows that the user has an existing custom screen configuration,
  25. # and thus we will not bother them with a select-screen-profile prompt.
  26. if [ -r "$HOME/.screenrc" -a ! -e "$HOME/.screen-profiles/profile" -a ! -h "$HOME/.screen-profiles/profile" ]; then
  27.     exec /usr/bin/screen.real -c "$HOME/.screenrc" "$@"
  28.     exit $?
  29. fi
  30.  
  31. # If the user is running screen with some arguments, but has not selected
  32. # their profile yet, don't bother them with profile selection at this time
  33. if [ $# -gt 0 -a ! -h "$HOME/.screen-profiles/profile" ]; then
  34.     exec /usr/bin/screen.real "$@"
  35.     exit $?
  36. fi
  37.  
  38. # Ensure that the user has selected a screen profile
  39. [ -h "$HOME/.screen-profiles/profile" ] || /usr/bin/select-screen-profile
  40. if [ ! -r "$HOME/.screen-profiles/profile" ]; then
  41.     echo
  42.     echo "Your selected profile is not accessible."
  43.     echo
  44.     echo "Either select a different profile:"
  45.     echo " $ select-screen-profile"
  46.     echo
  47.     echo "Or install the extras package:"
  48.     echo " $ sudo apt-get install screen-profiles-extras"
  49.     echo
  50.     exit 1
  51. fi
  52.  
  53. # Ensure that their keybindings are seeded
  54. [ -s "$HOME/.screen-profiles/keybindings" ] || echo "source /usr/share/screen-profiles/keybindings/common" > "$HOME/.screen-profiles/keybindings"
  55.  
  56. # Ensure that their default windows are seeded
  57. [ -r "$HOME/.screen-profiles/windows" ] || cp "/usr/share/screen-profiles/windows/common" "$HOME/.screen-profiles/windows"
  58.  
  59. # Ensure that the user's .screenrc at least exists
  60. [ -r "$HOME/.screenrc" ] || touch "$HOME/.screenrc"
  61.  
  62. # Now let's execute screen!
  63. exec /usr/bin/screen.real -c "$HOME/.screen-profiles/profile" "$@"
  64.